#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<unordered_map>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef long long LL;
const LL mod=1e9+7;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
vector<LL>g[maxn];
template<typename A,typename B>
struct unmap{
    struct node{
        A u;B v;int nxt;
    };
    static const unsigned uN=20000003;
    vector<node>e;
    int head[uN];
    unmap(){memset(head,-1,sizeof(head));}
    bool count(A u){
        int hs=u%uN;
        for(int i=head[hs];~i;i=e[i].nxt)
            if(e[i].u==u) return 1;
        return 0;
    }
    B &operator[](A u){
        int hs=u%uN;
        for(int i=head[hs];~i;i=e[i].nxt)
            if(e[i].u==u) return e[i].v;
        e.push_back({u,B(),head[hs]}),head[hs]=e.size()-1;
        return e.back().v;
    }
};
unmap<LL,LL>map1[maxn];
//unordered_map<LL,LL>map1[maxn];
//unordered_map<LL,LL>map1[maxn];
LL val[maxn];
LL ans;
void dfs(LL u,LL fa){

     for(LL j=0;j<map1[fa].size();j++){
         ans=(ans%mod+__gcd(val[u],j.first)%mod*j.second%mod)%mod;
     }
     ans=(ans%mod+val[u]%mod)%mod;
     map1[u][val[u]]++;
     for(auto j:map1[fa]){
         map1[u][__gcd(val[u],j.first)]+=j.second;
     }
     for(LL i=0;i<g[u].size();i++){
         LL v=g[u][i];
         if(v==fa) continue;
         dfs(v,u);
     }
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n;cin>>n;
   for(LL i=1;i<=n;i++) cin>>val[i];
   for(LL i=1;i<n;i++){
       LL u,v;cin>>u>>v;
       g[u].push_back(v);
       g[v].push_back(u);
   }
   dfs(1,0);
   cout<<ans<<"\n";
   return 0;
}
